package com.itcast.demo11;

import java.util.Date;

public class Student implements Comparable<Student> {
    private  int id;
    private  String zuo;
    private Date brithday;
    public Student() {
    }

    public Student(int id, String zuo, Date brithday) {
        this.id = id;
        this.zuo = zuo;
        this.brithday = brithday;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getZuo() {
        return zuo;
    }

    public void setZuo(String zuo) {
        this.zuo = zuo;
    }

    public Date getBrithday() {
        return brithday;
    }

    public void setBrithday(Date brithday) {
        this.brithday = brithday;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", zuo='" + zuo + '\'' +
                ", brithday=" + brithday +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        return false;
    }

    @Override
    public int hashCode() {
        String[] ab = zuo.split("位");
        String s = ab[1];
        int i = Integer.parseInt(s);
        return i;
    }

    @Override
    public int compareTo(Student o) {
        long time = brithday.getTime();
        long time1 = o.getBrithday().getTime();
        long time3= time-time1;
        if (time3 > 0) {
            return 1;
        } else if (time3 == 0) {
            return 0;
        } else {
            return -1;
        }
    }
}
